<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>新增账号</title>

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /><!-- 控制浏览器文件模式为IE8 -->
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="js/artDialog/skins/default.css" rel="stylesheet" type="text/css" />
<link href="css/sele.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/artDialog/artDialog.js?skin=blue"></script>
<script src="js/artDialog/plugins/iframeTools.js"></script>
<script type="text/javascript" src="js/operamasks-ui.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/elegant/om-all.css" />
<style>
td,span,textarea{
 font-size:11pt;
}
	.dfinput {font-family: Microsoft YaHei,Microsoft JhengHei;font-size:11pt;border: #9DCBE2 solid 1px;width: 80%;height: 30px;line-height: 30px;float: left;}
	select {width: 200px;height: 30px;line-height: 30px;font-size:11pt;border: #9DCBE2 solid 1px;}
	label{float: left;width: 15px;margin-top: 6px}
	textarea {font-family: Microsoft YaHei,Microsoft JhengHei;width: 100%;height: 65px;border: #9DCBE2 solid 1px;}
	.dir{width:100%; border-left:#d0dee5 solid 1px;border-top:#d0dee5 solid 1px;border-collapse:collapse;}
	.dir td{border-right:#d0dee5 solid 1px;border-bottom:#d0dee5 solid 1px;padding:5px 5px 5px;vertical-align: middle;}
</style>
<script>
	function submitForm() {
		var roleCode = document.getElementById("roleCode").value;
		var roleId = document.getElementById("roleId").value;
		var roleName = document.getElementById("roleName").value;
		var description = document.getElementById("description").value;
		
		if(roleCode == null || roleCode == ""){
			art.dialog.tips('用户名称不能为空！', 1.5);
			return;	
		}
		if(roleName == null || roleName == ""){
			art.dialog.tips('角色名稱不能为空！', 1.5);
			return;
		}								
		
		$.ajax({
			url: "${pageContext.request.contextPath}/role.do?action=roleEdit",
			cache: false,
			async: false,
			type: 'post',
			dataType: "text",
			data: { 
				"roleId" : roleId,
				"roleCode" : roleCode,
				"roleName" : roleName,
				"description" : description
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {
	           alert(XMLHttpRequest.status);
	           alert(XMLHttpRequest.readyState);
	           alert(textStatus);
	           alert("操作失败,请联系管理员!");
	       },
			success:function(data){ //请求成功后处理函数
				if(data == "SUCCESS"){
					alert("修改成功!");
					window.location.href="role.do?action=roleList01";
				}else{
					alert("修改失敗!");
				}
			}
		}); 
	}
	function checkName(obj){
		var t=/.*[\u4e00-\u9fa5]+.*$/;
		if(obj != ""){
			if(t.test(obj)){
				art.dialog.tips('不能包含汉字！', 1.5);
			}
			else {j.ajax( {
				url : './adminUser.do?action=checkName&userName='+obj,
				date : '',
				type : 'GET',
				dateType : 'xml',
				timeout : 100000,
				error : function(xml) {
					j.omMessageBox.alert({
				           content:'响应失败！',
				           onClose:function(v){}
				    });
				},
				success : function(xml) {
					var $message = j(xml).find("user").children("stat").text();
					if ($message == 'have') {
						uflag = false;
						j.omMessageBox.alert({
					           content:'警告信息：该帳號已经被使用或該員工不存在，请重新输入！',
					           onClose:function(v){document.getElementById("userName").value = "";}
					    });
					} else if($message == 'notipebg') {
						j.omMessageBox.alert({
					           content:'警告信息：该員工尚沒開通一帳通賬號，請先開通一帳通賬號！',
					           onClose:function(v){document.getElementById("userName").value = "";}
					    });
					} else if($message == 'timeout') {
						j.omMessageBox.alert({
					           content:'警告信息：已超时，请重新登录！',
					           onClose:function(v){window.parent.parent.location.href="login.jsp"}
					    });
					}else{
						uflag = true;
						return;
					}
				}
			});
			}
		}
	}
</script>
</head>
<body>

	<div class="place">
	    <span>位置：</span>
	    <ul class="placeul">
	    <li>首页</li>
		<li>系统管理</li>
	    <li><a href="#" onclick="javascript:window.location.href='./adminUser.do?action=list'">角色管理</a></li>
		<li>修改角色</li>
	    </ul>
    </div>
     <div class="formbody">
     <input id="roleId" type="hidden" name="roleCode"  style="width:300px;height:32px;"   value="${roleBean.roleId}"/>
     <div class="formtitle"><span>基本信息</span></div>
		<form id="form1" action="./adminUser.do?action=addUser" method="post">	
	<div style="margin-top:10px">
			<ul class="forminfo">
				<li>
					<label style="width:70px;display:inline-block">角色代碼：</label>
					<input id="roleCode" type="text" <%-- onblur="checkName(this.value);" --%> name="roleCode"  style="width:300px;height:32px;" class="scinput"  value="${roleBean.roleCode}"/>					
					<i>*必填</i>
				</li>				
			</ul>
			<ul class="forminfo">
				<li>
					<label style="width:70px;display:inline-block">角色名稱：</label>
					<input id="roleName" type="text" name="roleName" style="width:300px;height:32px;" class="scinput" value="${roleBean.roleName}"/>
					<i>*必填</i>
				</li>				
			</ul>
			<ul class="forminfo">
				<li>
					<label style="width:70px;display:inline-block">描述：</label>			
					<textarea   rows="4" style="width:300px;" name="description" id="description" >${roleBean.description}</textarea>													
				</li>				
			</ul>
          	<ul class="forminfo" style="margin-top:30px;">
			    <li>
					<label>&nbsp;</label>
					<input name="" type="button" id="save" onclick="submitForm();" class="btn" value="确定修改"/> 
					<input style="margin-left:100px;" onclick="javascript:document.location.href = './role.do?action=roleList01';" type="button" class="cancel" value="取消修改" />
				</li>
		    </ul> 
		    </div>  
	    </form>
	</div>
	
</body>
</html>